fix(export): match harness allowedTools for customer tools and keep model parameters - #2456
Conversation
247d056 to
86eca92
Compare
86eca92 to
667fe6c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #2456 +/- ##
=========================================
Coverage 97.35% 97.36%
=========================================
Files 632 632
Lines 46268 46296 +28
=========================================
+ Hits 45044 45075 +31
+ Misses 1224 1221 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
667fe6c to
e69b854
Compare
| const allowed = | ||
| tool.type === "inline_function" | ||
| ? matchesAllowedTools(tool.name, tool.name, allowedPatterns) | ||
| : isServerAllowed(tool.name, allowedPatterns); |
There was a problem hiding this comment.
is tool filter being preserved here?
for eg: @exa/search should expose only /search, but the export keeps the whole Exa server without the filter, exposing all its tools. Could we pass the tool pattern to MCPClient.tool_filters?
There was a problem hiding this comment.
Good catch, thanks. @server/tool now narrows the MCP server through MCPClient(tool_filters=...), matching the server's own tool name or <server>_<tool> (the harness accepts both). @exa and * still load every tool. Checked against a live MCP server: @local/order_* loads only order_status.
e69b854 to
98aac5e
Compare
98aac5e to
f82402a
Compare
| modelId: model.modelId, | ||
| modelApiFormat: model.apiFormat, | ||
| // Provider parameters; the explicit model settings below take precedence over them. | ||
| modelAdditionalParams: |
There was a problem hiding this comment.
had my agent test this e2e and seems like preserving guardrailConfig causes exported runtimes to call Bedrock guardrails, but the generated role lacks bedrock:ApplyGuardrail, so invocation fails with AccessDenied. can we please generate that policy?
There was a problem hiding this comment.
Good catch. When bedrockModelConfig.additionalParams sets a guardrailConfig, the export now adds a bedrock:ApplyGuardrail policy (bedrock-guardrail-policy.json) to the runtime role, scoped to the guardrail ARN, or to guardrail/<id> when only an ID is given.
| top_p={{modelTopP}}, | ||
| {{/if}} | ||
| {{#if modelAdditionalParams}} | ||
| additional_args=json.loads({{pyJsonStr modelAdditionalParams}}), |
There was a problem hiding this comment.
Could we ensure the explicit model settings take priority? Strands applies additional_args after max_tokens, temperature, and top_p; an inferenceConfig inside additionalParams therefore overrides those explicit settings.
for eg, additionalParams.inferenceConfig.maxTokens currently overrides max_tokens, even though the code intends the explicit value to win.
There was a problem hiding this comment.
You're right that additional_args wins on Bedrock Converse. The harness behaves the same way: it builds BedrockModel with the explicit settings plus additional_args, and Strands applies those last. So the export matches the harness here, and changing the precedence only in the export would make the two diverge. The comment claiming explicit settings win was wrong; it now says what the harness docs say: provider-specific parameters are passed through to the model provider unchanged. On OpenAI, Gemini, LiteLLM, and Mantle the explicit settings still take precedence, in both the harness and the export.
There was a problem hiding this comment.
Okay I see, makes sense to me!
…odel parameters - allowedTools: a bare pattern selects builtins only, and @server selects a customer tool (MCP server, inline function, gateway, browser, code interpreter), as the harness runtime does. Previously @server dropped the tool and a bare name kept it; a bare builtin name ("shell") now also selects the builtin, as intended. - @server/tool narrows an MCP server to the matching tools through MCP tool filters, matched on the server's own tool name or <server>_<tool>, as the harness does. - Service model additionalParams for bedrock, open_ai, and gemini are carried into the generated model loader instead of being dropped with a note. A Bedrock guardrailConfig in them adds a bedrock:ApplyGuardrail policy to the runtime role. The local harness spec still omits them, since its deploy schema accepts them only for lite_llm.
f82402a to
e697e61
Compare
Description
agentcore export harnessnow matches the harness it exports in two places:allowedToolsfor configured tools. A bare pattern (shell,file_*) selects built-in tools only, and@nameselects a configured tool (MCP server, inline function, gateway, browser, code interpreter), as the harness does. Previously@namedropped the tool and a barenamekept it. A bare built-in name such asshellnow also selects the built-in, which previously required@builtin/shell.matchesAllowedToolsnow takes the server and tool separately instead of a flattened name.@server/toolfor MCP servers. A pattern that names specific tools (@exa/search,@exa/web_*) now narrows the MCP server to those tools throughMCPClient(tool_filters=...), matched on the server's own tool name or<server>_<tool>. Previously the whole server was kept, exposing all of its tools.@exaand*still load every tool.additionalParams. Forbedrock,open_ai, andgemini,export harness --arncarries the harness model'sadditionalParamsinto the generatedmodel/load.py(Bedrockadditional_args;paramsfor Mantle, OpenAI, and Gemini) instead of dropping them with an export note. Explicit model settings (temperature, max tokens, ...) take precedence. The local harness spec still omits the field, sinceharness.yamlaccepts it only forlite_llm, so the values are passed to the export alongside the spec.Behavior changes for new exports: a bare configured-tool name in
allowedToolsno longer keeps that tool (use@name), matching the harness.Related Issue
Closes #2455
Documentation PR
Not applicable.
Type of Change
Testing
bun testbun run test:e2e, or explained why they are not applicable: there are no export end-to-end tests. Instead I rendered an export and ran it against Bedrock:allowedTools: ["@mcp"]kept the MCP server and the model called its tool;@mcp/order_*loaded only the matching tool, and Bedrock accepted the carried-overadditionalParams.bun run typecheckbun run lint:checkbun run format:checkbun run buildsrc/assets/, I updated affected snapshots withbun test <test-file> --update-snapshotsand committed them (no snapshots changed)Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.